package com.geekteam.manga.provider;


import android.net.Uri;
import android.provider.BaseColumns;
import android.provider.ContactsContract;
import android.text.TextUtils;

public class MangaContract {
	
	public MangaContract(){
		
	}
	
	public interface ContentMangaColumns{
		public String MANGA_ID = "Manga_Id";
		public String MANGA_CHAPID = "Chap_Id";
		public String MANGA_CONTENT = "ContentManga_Content";
		
	}
	
	public interface RecentMangaColumns{
		public String MANGA_ID = "Manga_Id";
		public String RECENTMANGA_TIME = "RecentManga_Time";
	}
	
	public interface MangaChapColumns{
		public String MANGA_ID = "Manga_Id";
		public String MANGACHAP_CHAPID = "Chap_Id";
		public String MANGACHAP_NAME = "MangaChap_Name";
		public String MANGACHAP_NUMBER = "MangaChap_Number";
	}
	
	public interface MangaColumns{
		public String MANGA_ID = "Manga_Id";
		public String MANGA_TITLE = "Manga_Title";
	    public String MANGA_LIKENUMBER = "Manga_LikeNumber";
	    public String MANGA_VIEWNUMBER = "Manga_ViewNumber";
	    public String MANGA_URLCOVER = "Manga_UrlCover";
	    public String MANGA_DESCRIPTION = "Manga_Description";
	    public String MANGA_FAVORITE = "Manga_favorite";
	    public String MANGA_AUTHOR = "Manga_Author";
	    public String MANGA_SOURCE = "Manga_Source";
	}
	
	public static final String CONTENT_AUTHORITY = "com.geekteam.manga";
	public static final Uri BASE_CONTENT_URI = Uri.parse("content://"
			+ CONTENT_AUTHORITY);
	
	private static final String PATH_MANGA = "manga";
	private static final String PATH_MANGACHAP = "mangachap";
	private static final String PATH_RECENTMANGA = "recentmanga";
	private static final String PATH_CONTENTMANGA = "contentmanga";
	
	
        public static class Manga implements MangaColumns,BaseColumns{
		
		public static final  Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_MANGA).build();
	
		public static final String CONTENT_TYPE =
             "vnd.android.cursor.dir/vnd.manga.manga";
		public static final String CONTENT_ITEM_TYPE =
             "vnd.android.cursor.item/vnd.manga.manga";
		
		public static Uri buildMangaCategoryUri(){
        	return CONTENT_URI.buildUpon().build();
        }
        
        public static String getMangaId(Uri uri){
        	return uri.getPathSegments().get(1);
        }
     
	}
        
        public static class MangaChap implements MangaChapColumns,BaseColumns{
    		
    		public static final  Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_MANGACHAP).build();
    	
    		public static final String CONTENT_TYPE =
                 "vnd.android.cursor.dir/vnd.manga.mangachap";
    		public static final String CONTENT_ITEM_TYPE =
                 "vnd.android.cursor.item/vnd.manga.mangachap";
    		
    		public static Uri buildMangaChapCategoryUri(){
            	return CONTENT_URI.buildUpon().build();
            }
            
            public static String getMangaChapId(Uri uri){
            	return uri.getPathSegments().get(1);
            }
         
    	}
        
 public static class RecentManga implements RecentMangaColumns,BaseColumns{
    		
    		public static final  Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_RECENTMANGA).build();
    	
    		public static final String CONTENT_TYPE =
                 "vnd.android.cursor.dir/vnd.manga.recentmanga";
    		public static final String CONTENT_ITEM_TYPE =
                 "vnd.android.cursor.item/vnd.manga.recentmanga";
    		
    		public static Uri buildRecentMangaCategoryUri(){
            	return CONTENT_URI.buildUpon().build();
            }
            
            public static String getRecentMangaId(Uri uri){
            	return uri.getPathSegments().get(1);
            }
         
    	}
 
 	public static class ContentManga implements ContentMangaColumns,BaseColumns{
		
		public static final  Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_CONTENTMANGA).build();
	
		public static final String CONTENT_TYPE =
          "vnd.android.cursor.dir/vnd.manga.contentmanga";
		public static final String CONTENT_ITEM_TYPE =
          "vnd.android.cursor.item/vnd.manga.contentmanga";
		
		public static Uri buildContentMangaCategoryUri(){
     	return CONTENT_URI.buildUpon().build();
     }
     
     public static String getContentMangaId(Uri uri){
     	return uri.getPathSegments().get(1);
     }
  
	}

 	public static boolean hasCallerIsSyncAdapterParameter(Uri uri) {
        return TextUtils.equals("true",
                uri.getQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER));
    }
 	
}
